package com.ztjy.sys.biz.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ztjy.bean.Job;
import com.ztjy.sys.biz.JobBiz;
import com.ztjy.sys.dao.JobDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class JobBizImpl implements JobBiz {
    @Autowired
    private JobDao jdao;

    @Override
    public Job findJobById(Integer jid) {
        return jdao.findJobById(jid);
    }

    @Override
    public List<Job> findAllJobs(Job job) {
        return jdao.findAllJobs(job);
    }

    @Override
    public PageInfo<Job> findAllJobsPage(Job job, Integer pageNo, Integer pageSize) {
        PageHelper.startPage(pageNo, pageSize);
        List<Job> allJobs = jdao.findAllJobs(job);
        PageInfo<Job> jobBizPageInfo = new PageInfo<Job>(allJobs);
        return jobBizPageInfo;
    }

    @Override
    public boolean addJob(Job job) {
        boolean flag = false;
        try {
            flag = jdao.addJob(job);
        } catch (Exception e) {
            e.printStackTrace();
            flag = false;
        }
        return flag;
    }

    @Override
    public boolean updateJob(Job job) {
        boolean flag = false;
        try {
            flag = jdao.updateJob(job);
        } catch (Exception e) {
            e.printStackTrace();
            flag = false;
        }
        return flag;
    }
}
